package com.xq.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


import com.xq.cloud.entity.User;
import com.xq.cloud.repository.UserRepository;

@RestController
public class UserController {
	
	@Autowired 
	private UserRepository userRepository;
	
	@Autowired
	private DiscoveryClient discoveryClient;
	
	
	@GetMapping("/simple/{id}")
	public User findById(@PathVariable Long id){
		return this.userRepository.findOne(id);
	}
	
	@GetMapping("/instance-info")
    public ServiceInstance showInfo() {
		ServiceInstance localServiceInstance = this.discoveryClient.getLocalServiceInstance();
		return localServiceInstance;
    }
	
	

}
